package root.electronclass.electronclass.ext

import android.graphics.Outline
import android.view.View
import android.view.ViewOutlineProvider

/**
 *
 * @author Lokiy
 * @date 2023/4/1 10:21
 */

fun View.setRoundCorner(dp: Float) {
    outlineProvider = object : ViewOutlineProvider() {
        override fun getOutline(view: View?, outline: Outline?) {
            view ?: return
            outline?.setRoundRect(0, 0, view.width, view.height, dp.dp)
        }

    }
    clipToOutline = true
}